package server.init;


import cn.hutool.core.lang.Console;
import cn.hutool.json.JSONObject;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import server.http.HttpResponseContent;
import server.tool.SystemInfoTool;

import java.util.Objects;

@Configuration
public class Init {

    @Autowired(required = false)
//    @Qualifier("getMachineInfo")
    SystemInfoTool systemInfoTool;


    private static final Logger log = LogManager.getLogger(Init.class);

    @PostConstruct
    public void init() {
        Console.log("初始化");
        HttpResponseContent content = new HttpResponseContent();
        content.init();// 初始化
        if (Objects.nonNull(systemInfoTool)) {
            systemInfoTool.setInfo();
        }else{
            Console.error("机器配置实例为空");
        }
        JSONObject info = systemInfoTool.getMachineInfo();
    }
}
